package net.viralpatel.spring;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice //可以处理所有Controller的问题
public class ExceptionControllerAdvice {

	@ExceptionHandler( Exception.class )
	public ModelAndView exception(Exception e){

		ModelAndView mav = new ModelAndView("exception"); // view name，会跳转到对应的jsp
		mav.addObject("name", e.getClass().getSimpleName());
		mav.addObject("message", e.getMessage());

		return mav;
	}
}
